package com.zhongke.common.viewadapter

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.zhongke.common.imageloader.loadCorner
import com.zhongke.common.imageloader.loadNormal
import com.zhongke.common.utils.dp

/**
 *@Date: 2022/3/2
 *@Time: 11:43
 *@Author:cxc
 *@Description: 图片加载ViewAdapter
 */
object ImageViewAdapter {

    /**
     * 加载圆角图片
     * @param imageView ImageView
     * @param url String?
     * @param radius Int
     */
    @BindingAdapter(value = ["imgLoadCorner", "imgRadius"], requireAll = false)
    @JvmStatic
    fun loadCorner(imageView: ImageView, url: String?, radius: Int = 0) {
        imageView.loadCorner(url,radius)
    }

    /**
     * 加载圆形
     * @param imageView ImageView
     * @param url String?
     */
    @BindingAdapter(value = ["imgLoadRound"], requireAll = false)
    @JvmStatic
    fun loadRound(imageView: ImageView, url: String?) {
        imageView.loadCorner(url)
    }


    @BindingAdapter(value = ["imgLoadNormal"], requireAll = false)
    @JvmStatic
    fun loadNormal(imageView: ImageView, url: String?) {
        imageView.loadNormal(url)
    }
}
